// pages/index4/index4.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    text: ""

  },



  async onLoad(options) {
    const res = await this.getDataList()
    this.setData({
      list: res.data
    })
    console.log(res)
  },
  getDataList() {
    const promise = new Promise(resolve => {
      wx.request({
        url: 'https://api-vue-base.itheima.net/api/lol/search',
        data: {
          q: this.data.text
        },
        success: (res => {
          resolve(res.data)
        })

      })
    })
    return promise

  },
  async onSearch() {
    // wx.showToast({
    //   title: this.data.text,
    // })
    const res = await this.getDataList()

    this.setData({
      list: res.data
    })
  }


})